
FROM php:7.2.2-fpm
#其他扩展参考地址 https://www.jianshu.com/p/20fcca06e27e
# 官方版本默认安装扩展: 
# Core, ctype, curl
# date, dom
# fileinfo, filter, ftp
# hash
# iconv
# json
# libxml
# mbstring, mysqlnd
# openssl
# pcre, PDO, pdo_sqlite, Phar, posix
# readline, Reflection, session, SimpleXML, sodium, SPL, sqlite3, standard
# tokenizer
# xml, xmlreader, xmlwriter
# zlib


ENV PHPREDIS_VERSION 3.1.3
#修改源
RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
	echo 'deb http://mirrors.aliyun.com/debian stretch main contrib non-free' > /etc/apt/sources.list && \
	echo 'deb http://mirrors.aliyun.com/debian stretch-proposed-updates main contrib non-free' >> /etc/apt/sources.list && \
	echo 'deb http://mirrors.aliyun.com/debian stretch-updates main contrib non-free' >> /etc/apt/sources.list && \
	echo 'deb-src http://mirrors.aliyun.com/debian stretch main contrib non-free' >> /etc/apt/sources.list && \
	echo 'deb-src http://mirrors.aliyun.com/debian stretch-proposed-updates main contrib non-free' >> /etc/apt/sources.list && \
	echo 'deb-src http://mirrors.aliyun.com/debian stretch-updates main contrib non-free' >> /etc/apt/sources.list && \
	echo 'deb http://mirrors.aliyun.com/debian-security/ stretch/updates main non-free contrib' >> /etc/apt/sources.list && \
	echo 'deb-src http://mirrors.aliyun.com/debian-security/ stretch/updates main non-free contrib' >> /etc/apt/sources.list && \
	echo 'deb http://mirrors.aliyuncs.com/debian stretch main contrib non-free' >> /etc/apt/sources.list && \
	echo 'deb http://mirrors.aliyuncs.com/debian stretch-proposed-updates main contrib non-free' >> /etc/apt/sources.list && \
	echo 'deb http://mirrors.aliyuncs.com/debian stretch-updates main contrib non-free' >> /etc/apt/sources.list && \
	echo 'deb-src http://mirrors.aliyuncs.com/debian stretch main contrib non-free' >> /etc/apt/sources.list && \
	echo 'deb-src http://mirrors.aliyuncs.com/debian stretch-proposed-updates main contrib non-free' >> /etc/apt/sources.list && \
	echo 'deb-src http://mirrors.aliyuncs.com/debian stretch-updates main contrib non-free' >> /etc/apt/sources.list && \
	echo 'deb http://mirrors.aliyuncs.com/debian-security/ stretch/updates main non-free contrib' >> /etc/apt/sources.list && \
	echo 'deb-src http://mirrors.aliyuncs.com/debian-security/ stretch/updates main non-free contrib' >> /etc/apt/sources.list 
	
#for redis and mysql
RUN curl -L -o /tmp/redis.tar.gz https://github.com/phpredis/phpredis/archive/$PHPREDIS_VERSION.tar.gz \
    && tar xfz /tmp/redis.tar.gz \
    && rm -r /tmp/redis.tar.gz \
    && mkdir -p /usr/src/php/ext \
    && mv phpredis-$PHPREDIS_VERSION /usr/src/php/ext/redis \
    && docker-php-ext-install redis \
       pdo_mysql \
       bcmath

# for uuid extention 不会重启fpm,先安装这个,下面的zip安装后,就会自动重启,然后就可以使用了
RUN  apt-get update && apt-get install -y uuid uuid-dev \
     && pecl install  uuid \
     && echo 'extension=uuid.so' >> /usr/local/etc/php/conf.d/php-uuid.ini
	 
# for swoole extention 不会重启fpm,先安装这个,下面的zip安装后,就会自动重启,然后就可以使用了
RUN echo '' | pecl install  swoole \
    && echo 'extension=swoole.so' >> /usr/local/etc/php/conf.d/php-swoole.ini
     
#for composer
RUN php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" \
    && php composer-setup.php \
    && mv composer.phar /usr/local/bin/composer \
	&& chmod +x /usr/local/bin/composer \
	&& composer self-update \
	&& composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
	
# for zip
RUN apt-get install -y --no-install-recommends libzip-dev \
    && rm -r /var/lib/apt/lists/* \
    && docker-php-ext-install -j$(nproc) zip
	
	
#for git
#RUN apt-get update && apt-get install -y git





#for gd 图片管理
#RUN apt-get update && apt-get install -y \
#        libfreetype6-dev \
#        libjpeg62-turbo-dev \
#        libpng-dev \
#    && docker-php-ext-install -j$(nproc) iconv \
#    && docker-php-ext-configure gd --with-freetype-dir=/usr/include/ --with-jpeg-dir=/usr/include/ \
#    && docker-php-ext-install -j$(nproc) gd


# for grpc extention
#RUN  apt-get install -y \
#        libmemcached-dev zlib1g-dev \
#    && pecl install grpc \
#    && pecl install protobuf \
#    && rm -rf /usr/src/php


#for rabbitmq
#RUN apt-get -qq update && apt-get -qq -y install  \
#         automake \
#         cmake \
#         g++ \
#         git \
#         libicu-dev \
#         libmagickwand-dev \
#         librabbitmq-dev \
#         libreadline-dev \
#         pkg-config \
#         ssh-client \
#         supervisor \
#    && docker-php-ext-install \
#         sockets \
#         intl \
#    && git clone git://github.com/alanxz/rabbitmq-c.git \
#    && cd rabbitmq-c \
#    && mkdir build && cd build \
#    && cmake -DENABLE_SSL_SUPPORT=OFF .. \
#    && cmake --build . --target install  \
#    && pecl install amqp imagick xdebug igbinary \
#    && docker-php-ext-enable amqp imagick xdebug igbinary \
#    && version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") \
#    && curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version \
#    && mkdir -p /tmp/blackfire \
#    && tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp/blackfire \
#    && mv /tmp/blackfire/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so \
#    && printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini \
#    && curl -A "Docker" -L https://blackfire.io/api/v1/releases/client/linux_static/amd64 | tar zxp -C /tmp/blackfire \
#    && mv /tmp/blackfire/blackfire /usr/bin/blackfire \
#    && rm -rf /tmp/blackfire /tmp/blackfire-probe.tar.gz \
#    && rm -rf /var/lib/apt/lists/*